package offer;

public class offerII_0005 {
    public int maxProduct(String[] words) {
        int len=words.length;
        int[][] list=new int[len][26];
        for(int i=0;i<len;++i){
            for(int k=0;k<words[i].length();++k){
                list[i][words[i].charAt(k)-'a']+=1;
            }
        }
        int max=0;
        for(int i=0;i<len;++i){
            for(int j=i+1;j<len;++j){
                if(bool(list[i],list[j])){
                    max=Math.max(max,words[i].length()*words[j].length());
                }
            }
        }
        return max;
    }
    public boolean bool(int[] a,int[] b){
        for(int i=0;i<26;++i){
            if(a[i]>0&&b[i]>0) return false;
        }
        return true;
    }
}
